<?xml version="1.0"?>

<st-source>
<time-stamp>From VisualWorks® NonCommercial, 7.6 of March 3, 2008 on March 12, 2009 at 4:56:41 pm</time-stamp>


<class>
<name>InventoryTest</name>
<environment>SupplyChain</environment>
<super>XProgramming.SUnit.TestCase</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>inventory i1 i2 i3 i4 i5 </inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category></category>
<attributes>
<package>SupplyChain</package>
</attributes>
</class>

<!-- -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -   -->


<methods>
<class-id>SupplyChain.InventoryTest class</class-id> <category>instance creation</category>

<body package="SupplyChain" selector="new">new
	"Answer a newly created and initialized instance."

	^super new initialize</body>
</methods>

<!-- -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -   -->


<comment>
<class-id>SupplyChain.InventoryTest</class-id>
<body>This is the provided test class for M1.  You should not need to edit the class yourself.

To run, either install the RBSunit extension parcel and run from the system browser OR

highlight this code

TestRunner open

and doit.

Instance Variables:
	i1	&lt;Item&gt; a test item instance
	i2	&lt;Item&gt;	a test item instance
	i3	&lt;Item&gt;	a test item instance
	i4	&lt;Item&gt;	a test item instance
	i5	&lt;Item&gt;	a test item instance
	inventory	&lt;Inventory&gt;	an instance of the inventory class for test

</body>
</comment>

<methods>
<class-id>SupplyChain.InventoryTest</class-id> <category>accessing</category>

<body package="SupplyChain" selector="i1">i1
	^i1</body>

<body package="SupplyChain" selector="i1:">i1: anObject
	i1 := anObject</body>

<body package="SupplyChain" selector="i2">i2
	^i2</body>

<body package="SupplyChain" selector="i2:">i2: anObject
	i2 := anObject</body>

<body package="SupplyChain" selector="i3">i3
	^i3</body>

<body package="SupplyChain" selector="i3:">i3: anObject
	i3 := anObject</body>

<body package="SupplyChain" selector="i4">i4
	^i4</body>

<body package="SupplyChain" selector="i4:">i4: anObject
	i4 := anObject</body>

<body package="SupplyChain" selector="i5">i5
	^i5</body>

<body package="SupplyChain" selector="i5:">i5: anObject
	i5 := anObject</body>

<body package="SupplyChain" selector="inventory">inventory
	^inventory</body>

<body package="SupplyChain" selector="inventory:">inventory: anObject
	inventory := anObject</body>
</methods>

<methods>
<class-id>SupplyChain.InventoryTest</class-id> <category>Running</category>

<body package="SupplyChain" selector="setUp">setUp
   "Create test objects.  This is called before every individual test"
   inventory := Inventory new.
   i1 := Item named: 'Video Game' sku:'89X999'.
   i2 := Item named: 'TV' sku: '99Z837'.
   i3 := Item named: 'VCR' sku: '54Y3632'.
   i4 := Item named: 'PC' sku: '01P6373'.
   i5 := Item named: 'Laptop' sku: '11F4732'.</body>

<body package="SupplyChain" selector="testGetReorderItems">testGetReorderItems
   | coll |
   self setUpPrices.
   coll := inventory getReorderItems.
   self assert: coll size = 2.
   self assert: (coll includes: i1).
   self assert: (coll includes: i4).</body>

<body package="SupplyChain" selector="testInventoryAddItem">testInventoryAddItem
     self assert: inventory items size = 0.
     inventory addItem: i1.
    self assert: inventory items size = 1.
    self assert: (inventory items includes: i1).
    inventory addItem: i2.
    self assert: inventory items size = 2.
    self assert: (inventory items includes: i2).</body>

<body package="SupplyChain" selector="testInventoryPotentialProfit">testInventoryPotentialProfit
   self setUpPrices.
   Transcript show: inventory potentialProfit printString.
   self assert: inventory potentialProfit = 442.</body>

<body package="SupplyChain" selector="testInventoryPrintInventoryReport">testInventoryPrintInventoryReport
   self setUpPrices.
   inventory printInventoryReport</body>

<body package="SupplyChain" selector="testInventoryPrintString">testInventoryPrintString
   self setUpPrices.
   self assert: inventory printString = 'An Inventory of 5 items valued at 634 dollars'.</body>

<body package="SupplyChain" selector="testInventoryRemoveItem">testInventoryRemoveItem
    self addAllItems.
    self assert: (inventory items includes: i3).
    inventory removeItem: i3.
    self deny: (inventory items includes: i3).</body>

<body package="SupplyChain" selector="testInventorySortBlock">testInventorySortBlock
   self addAllItems.
   self assert: (inventory items at: 1) = i5.
   self assert: (inventory items at: 5) = i1.
   inventory sortBlock: [ :a :b | a sku &lt; b sku].
  self assert: (inventory items at: 1) = i4.
  self assert: (inventory items at: 5) = i2.</body>

<body package="SupplyChain" selector="testInventoryValue">testInventoryValue
   self setUpPrices.
   self assert: inventory inventoryValue = 634.</body>
</methods>

<methods>
<class-id>SupplyChain.InventoryTest</class-id> <category>initialize-release</category>

<body package="SupplyChain" selector="addAllItems">addAllItems
   "utility method to add all the items to the inventory"
   inventory addItem: i1.
   inventory addItem: i2.
  inventory addItem: i3.
  inventory addItem: i4.
  inventory addItem: i5.</body>

<body package="SupplyChain" selector="initialize">initialize
	"Initialize a newly created instance. This method must answer the receiver."

	" *** Edit the following to properly initialize instance variables ***"
	inventory := nil.
	i1 := nil.
	i2 := nil.
	i3 := nil.
	i4 := nil.
	i5 := nil.
	" *** And replace this comment with additional initialization code *** "
	^self</body>

<body package="SupplyChain" selector="setUpPrices">setUpPrices
   " utility method to add all items and set the internal data for tests"
   self addAllItems.
   i1 buyPrice: 3.
   i1 sellPrice: 7.
   i1 quantity: 8.
   i1 reorderPoint: 9.
   i2 buyPrice: 22.
   i2 sellPrice: 36.
   i2 quantity: 7.
   i2 reorderPoint: 6.
   i3 buyPrice: 18.
   i3 sellPrice: 40.
   i3 quantity: 3.
   i3 reorderPoint: 3.
   i4 buyPrice: 19.
   i4 sellPrice: 36.
   i4 quantity: 6.
   i4 reorderPoint: 7.
   i5 buyPrice: 24.
   i5 sellPrice: 36.
   i5 quantity: 12.
   i5 reorderPoint: 10.</body>
</methods>

</st-source>
